<template>
    <div class="px-8">
        <com-filterTable
            :ref="pageConfig.key"
            class=""
            :services="pageConfig.serviceHandle"
            :filter-form-config="pageConfig.formConfig"
            :filterInline="false"
            :params="{}"
            :filterCol="4"
            filterLabelWidth="90px"
            :table-border="true"
            :showFormFilter="true"
            :showRequestNum="false"
            :table-column="pageConfig.columnConfig"
            :queryDataHandle="queryDataHandle"
            :dataFormatHandle="dataFormatHandle"
            :autoLoad="true"
        />
    </div>
</template>

<script>
import { getOperlogList } from "@/service/api.js";
import moment from "moment";

export default {
    name: "operlog",
    data() {
        return {
            activeName: "filterTable",
            pageConfig: {
                key: "filterTable",
                serviceHandle: (data) => {
                    return getOperlogList(data);
                },
                params: {},
                formConfig: [
                    { key: "id", label: "操作编号" },
                    { key: "name", label: "名称" },
                ],
                columnConfig: [
                    { value: "id", label: "操作编号" },
                    { value: "name", label: "操作名称" },
                    { value: "code", label: "操作编码" },
                    { value: "description", label: "操作描述" },
                    { value: "status", label: "状态", 
                        formatter: (row) => {
                            return row.status ? "启用" : "禁用";
                        }
                    },
                    {
                        value: "createTime",
                        label: "创建时间",
                        width: 180,
                        formatter: (row) => {
                            return moment(row.createTime).format(
                                "YYYY-MM-DD HH:mm:ss"
                            );
                        },
                    },
                    {
                        value: "updateTime",
                        label: "更新时间",
                        width: 180,
                        formatter: (row) => {
                            return moment(row.updateTime).format(
                                "YYYY-MM-DD HH:mm:ss"
                            );
                        },
                    }
                ],
            },
        };
    },
    methods: {
        dataFormatHandle(data) {
            return {
                list: data.data,
                total: data.total,
            };
        },
        queryDataHandle(params) {
            return {
                ...params,
            };
        },
        loadList() {
            let ref = this.$refs[this.activeName];
            if (Array.isArray(ref)) {
                ref = ref[0];
            }
            ref.filterFormQueryHandle();
        },
    },
};
</script>
